<%@ page language="java" import="java.util.*,ms.platform.system.model.*"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>数据字典</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="<%=basePath%>js/bootstrap-3.3.6/dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/bootstrapValidator.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/mydialog.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/style.css" />
<script src="<%=basePath %>js/common/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=basePath %>js/rem.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript"src="<%=basePath%>js/common/dialog.3.1.min.js"></script>
<script type="text/javascript" src="<%=basePath %>js/bootstrap-3.3.6/dist/js/bootstrap.min.js" charset="utf-8"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			//删除字典
			$("span[name='deleteDict']").click(function(){
				var parentId = $("#parentId").val();
				var id=$(this).parent().attr("id");
				var grayScreen=document.getElementById("gray-screen");
				$.ajax({            
	                  type:"post",
	                  url:"<%=path%>/dict/deleteDict", 
	                  data:"id="+id,
	                  dataType:"json",
	                  success:function(data) {
	                	  if(data.message != undefined){
		                	  Dialog({
			  		                "msg": '<div class="D_alert">'+data.message+'</div>',
			  		                "title": "提示",
			  		                "showButtons": true,
			  		                "cancelButton": false,
			  		                "onComplete": function() {
			  		                	grayScreen.style.display="none";
			  		                	window.location.href="<%=path%>/dict/listData?parentId="+parentId;
			  		                }
			  		            });	 
	                	  }else{
	                  		  window.location.reload();
	                  	  }
	                  }
	            }); 
			});
			//清空搜索条件
			$(".clearForm").click(function(){
				$('#dictName').val("");
				$('#dictCode').val("");
			});
			//提交表单
			$(".queryForm").click(function(){
				var data=$("#queryForm").serialize();
				window.location.href="<%=path%>/dict/listData?"+data;
			});
			//跳转到添加页面
			$(".addRole").click(function(){
				var parentId = $("#parentId").val();
				window.location.href="<%=path%>/dict/toAddDictData?parentId="+parentId;
			});

			//跳转到编辑页面
			$("span[name='editDict']").click(function(){
		       var id=$(this).parent().attr("id");
		       window.location.href="<%=path%>/dict/toEditData?id="+id;
			});
			
			
			//改状态
			$("span[name='disabledAdmin']").click(function(){
				var id=$(this).parent().attr("id");
				var status=$(this).attr("isUsed");
				var parentId = $("#parentId").val();
				var grayScreen=document.getElementById("gray-screen");
				$.ajax({            
	                  type:"post",
	                  url:"<%=path%>/dict/statusData", 
	                  data:{id:id,status:status},
	                  dataType:"json",
	                  success:function(data) {
	                	  Dialog({
		  		                "msg": '<div class="D_alert">'+data.message+'</div>',
		  		                "title": "提示",
		  		                "showButtons": true,
		  		                "cancelButton": false,
		  		                "onComplete": function() {
		  		                	grayScreen.style.display="none";
		  		                	window.location.href="<%=path%>/dict/listData?parentId="+parentId;
		  		                }
		  		            });	 
	                  }
	            }); 
			});
		});

    </script>
</head>
<body>
	<div id="index-hav2">
		<div class="index-hav-right" id="index-hav-right-clear">
			<div class="row">
				<div class="col-md-9">
					<span id="icon-house"></span>
					<span id="arrows-left">首页</span>
					<span id="arrows-left">></span><span>系统管理</span><span id="arrows-left">></span><span>数据字典</span>
				</div>
				<div class="bank-box">
					<div class="lianlian platform">
						<div class="col-md-12">
							<form role="form" id="queryForm">
								<table class="textTable">
									<tr>
										<td class="platform-start">字典名称:</td>
										<th class="">
											<input type="text" id="dictName"  class="Wdate form-control input-sm" name="dictName" value="${map['dictName'] }">
										</th>
										<td class="platform-start">字典编码:</td>
										<th class="">
											<input type="hidden" name="parentId" id="parentId" value="${parentId}">
											<input type="text" id="dictCode" class="Wdate form-control input-sm" name="dictCode" value="${map['dictCode'] }">
										</th>
										
									</tr>
								</table>
								<ul class="textBtn">
								   <li class="">
										<button type="button" class="queryForm queryFormbtn-sub btn btn-primary btn-sm chaxun">查询</button>
										<button type="button" class="clearForm btn btn-primary btn-sm">重置</button>
										<button type="button" class="addRole btn btn-primary btn-sm">添加字典</button>
										<button type="button" class="btn btn-primary btn-sm" onclick="window.location.href='<%=path%>/dict/list'">返回</button>
									</li>
								</ul>
							</form>
							<table class="control-tatle table table-striped table-bordered table-hover" action="<%=path%>/dict/listData">
							<input type="hidden" name="group_Code" id ="groupCodeFlag" value="${groupCodeFlag }"/>
								<thead class="financing-thead">
									<tr>
										<th>字典编码</th>
										<th>字典名称</th>
										<th>字典说明</th>
										<th>字典状态</th>
										<th>创建时间</th>
										<th>更新时间</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${list }" var="dict">
										<tr>
											<td>${dict.dictCode }</td>
											<td>${dict.dictName }</td>
											<td>${dict.comment }</td>
											<td>
												<c:if test="${dict.status=='启用' }">启用</c:if> 
			                            		<c:if test="${dict.status=='禁用' }"><span style="color: red">禁用</span></c:if>
											</td>
											<td><fmt:formatDate value="${dict.createDate }" pattern="yyyy-MM-dd HH:mm:ss" /></td>
											<td><fmt:formatDate value="${dict.updateDate }" pattern="yyyy-MM-dd HH:mm:ss" /></td>
											<td id="${dict.id }">
												<c:if test="${dict.status=='启用' }">
														<span class="span1" name="disabledAdmin" isUsed='1' >禁用</span>
													</c:if> 
													<c:if test="${dict.status=='禁用' }">
														<span class="span1" name="disabledAdmin" isUsed='0'>启用</span>
													</c:if> 
												<input type="hidden" name ="status" value="${dict.status}"/>
												<span name="editDict" class="span1">编辑</span>
												<span name="deleteDict" class="span1">删除</span>
											</td>
										</tr>
									</c:forEach>
								</tbody>
								<tr style="background: #f8f8f8;">
									<td colspan="10"><jsp:include flush="false" page="/WEB-INF/jsp/page1.jsp"></jsp:include></td>
								</tr>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div id="gray-screen"></div>
</body>
</html>
